package com.itheima;

import com.itheima.dao.BookDao;
import com.itheima.service.BookService;
import com.itheima.service.impl.BookServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
//        BookService bookService = new BookServiceImpl();
//        bookService.save();
//        获取IOC容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

//        获取两次bean对象，验证bean的作用范围
//        BookService bookService = (BookService) ctx.getBean("service4");
//        System.out.println(bookService);
//        BookService bookService1 = (BookService) ctx.getBean("bookService");
//        System.out.println(bookService1);
//        bookService.save();

//        验证获取bean对象时，是否通过构造函数 - 是，执行了BookDaoImpl的无参构造函数中的打印语句
        BookDao dao =(BookDao) ctx.getBean("bookDao");
    }
}
